//
//  ANMineTicketDetailCell.m
//  WeiYiMei
//
//  Created by 李叶夫 on 2019/9/22.
//  Copyright © 2019 liyefu. All rights reserved.
//

#import "ANMineTicketDetailCell.h"

@interface ANMineTicketDetailCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *useConsumerLab;// 消费商户
@property (nonatomic, strong) UILabel *useConsumer;
@property (nonatomic, strong) UILabel *couponNameLab;// 优惠券名称
@property (nonatomic, strong) UILabel *couponName;
@property (nonatomic, strong) UILabel *memberCouponCodeLab; // 消费券码
@property (nonatomic, strong) UILabel *memberCouponCode;
@property (nonatomic, strong) UILabel *useTimeLab; // 消费时间
@property (nonatomic, strong) UILabel *useTime;
@property (nonatomic, strong) UILabel *consumerNameLab;// 发放商家
@property (nonatomic, strong) UILabel *consumerName;

@end

@implementation ANMineTicketDetailCell

+ (instancetype)cellForTableView:(UITableView *)tableView
{
    NSString *rid = NSStringFromClass([self class]);
    ANMineTicketDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:rid];
    if (!cell) {
        cell = [[ANMineTicketDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:rid];
        
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupSubViews];
    }
    return self;
}

- (void)setEntity:(TicketRecordEntity *)entity
{
    _entity = entity;
    self.useConsumer.text = String(entity.useConsumer);
    self.couponName.text = String(entity.couponName);
    self.memberCouponCode.text = String(entity.memberCouponCode);
    self.useTime.text = String(entity.useTime);
    self.consumerName.text = String(entity.consumerName);
}

- (void)setupSubViews
{
    self.backgroundColor = kColorF2F2F2;
    
    self.bgView = [[UIView alloc] init];
    self.bgView.backgroundColor = [UIColor whiteColor];
    
    self.useConsumerLab = [[UILabel alloc] init];
    self.useConsumerLab.textColor = kColor888888;
    self.useConsumerLab.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.useConsumerLab.text = @"使用商户";
    self.useConsumer = [[UILabel alloc] init];
    self.useConsumer.textColor = kColor333333;
    self.useConsumer.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.useConsumer.numberOfLines = 0;
    
    self.couponNameLab = [[UILabel alloc] init];
    self.couponNameLab.textColor = kColor888888;
    self.couponNameLab.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.couponNameLab.text = @"优惠券";
    self.couponName = [[UILabel alloc] init];
    self.couponName.textColor = kColor333333;
    self.couponName.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.couponName.numberOfLines = 0;
    
    self.memberCouponCodeLab = [[UILabel alloc] init];
    self.memberCouponCodeLab.textColor = kColor888888;
    self.memberCouponCodeLab.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.memberCouponCodeLab.text = @"优惠券码";
    self.memberCouponCode = [[UILabel alloc] init];
    self.memberCouponCode.textColor = kColor333333;
    self.memberCouponCode.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.memberCouponCode.numberOfLines = 0;
    
    self.useTimeLab = [[UILabel alloc] init];
    self.useTimeLab.textColor = kColor888888;
    self.useTimeLab.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.useTimeLab.text = @"使用时间";
    self.useTime = [[UILabel alloc] init];
    self.useTime.textColor = kColor333333;
    self.useTime.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.useTime.numberOfLines = 0;
    
    self.consumerNameLab = [[UILabel alloc] init];
    self.consumerNameLab.textColor = kColor888888;
    self.consumerNameLab.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.consumerNameLab.text = @"所属商户";
    self.consumerName = [[UILabel alloc] init];
    self.consumerName.textColor = kColor333333;
    self.consumerName.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
    self.consumerName.numberOfLines = 0;
    
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.useConsumerLab];
    [self.bgView addSubview:self.useConsumer];
    [self.bgView addSubview:self.couponNameLab];
    [self.bgView addSubview:self.couponName];
    [self.bgView addSubview:self.memberCouponCodeLab];
    [self.bgView addSubview:self.memberCouponCode];
    [self.bgView addSubview:self.useTimeLab];
    [self.bgView addSubview:self.useTime];
    [self.bgView addSubview:self.consumerNameLab];
    [self.bgView addSubview:self.consumerName];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView).offset(-10);
    }];
    
    [self.useConsumerLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgView).offset(10);
        make.left.equalTo(self.bgView).offset(20);
    }];
    [self.useConsumer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.useConsumerLab);
        make.left.equalTo(self.useConsumerLab.mas_right).offset(10);
        make.right.lessThanOrEqualTo(self.bgView).offset(-20);
    }];
    
    [self.couponNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.useConsumer.mas_bottom).offset(10);
        make.left.equalTo(self.useConsumerLab);
    }];
    [self.couponName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.couponNameLab);
        make.left.equalTo(self.couponNameLab.mas_right).offset(10);
        make.right.lessThanOrEqualTo(self.bgView).offset(-20);
    }];
    
    [self.memberCouponCodeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.couponName.mas_bottom).offset(10);
        make.left.equalTo(self.useConsumerLab);
    }];
    [self.memberCouponCode mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.memberCouponCodeLab);
        make.left.equalTo(self.memberCouponCodeLab.mas_right).offset(10);
        make.right.lessThanOrEqualTo(self.bgView).offset(-20);
    }];
    
    [self.useTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.memberCouponCode.mas_bottom).offset(10);
        make.left.equalTo(self.useConsumerLab);
    }];
    [self.useTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.useTimeLab);
        make.left.equalTo(self.useTimeLab.mas_right).offset(10);
        make.right.lessThanOrEqualTo(self.bgView).offset(-20);
    }];
    
    [self.consumerNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.useTime.mas_bottom).offset(10);
        make.left.equalTo(self.useConsumerLab);
    }];
    [self.consumerName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.consumerNameLab);
        make.left.equalTo(self.consumerNameLab.mas_right).offset(10);
        make.right.lessThanOrEqualTo(self.bgView).offset(-20);
        make.bottom.equalTo(self.bgView).offset(-10);
    }];
    
}

@end
